/**
 * Created by natalia on 10/1/14.
 */
public class Card implements Comparable<Card>{

    public int compareTo(Card o) {
        int level1 = this.level.getValue();
        int level2 = o.level.getValue();

        if( level1 != level2 ) {
            if(level1 > level2) {
                return -1;
            } else if(level1 < level2) {
                return 1;
            }
        }
        return 0;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Card card = (Card) o;

        if (colour != card.colour) return false;
        if (level != card.level) return false;
        if (suit != card.suit) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = suit != null ? suit.hashCode() : 0;
        result = 31 * result + (colour != null ? colour.hashCode() : 0);
        result = 31 * result + (level != null ? level.hashCode() : 0);
        return result;
    }

    protected enum SUIT {SPADE, HEART, DIAMOND, CLUB };

	public SUIT getSuit() {
		return suit;
	}

	public void setSuit(SUIT suit) {
		this.suit = suit;
	}

	protected SUIT suit;
	
	protected enum COLOUR {RED, BLACK}
	protected COLOUR colour;

	enum LEVELS {
		TWO(2), THREE(3), FOUR(4), FIVE(5), SIX(6), SEVEN(7), EIGHT(8), NINE(9), TEN(10), JACK(11), QUEEN(12), KING(13), TOUZ(14);
		private int val;

		private LEVELS(int i) {
			val = i;
		}

		public int getValue() {
			return val;
		}
	}

	protected LEVELS level;

	Card(SUIT suit,  COLOUR colour, LEVELS level) {
		this.suit = suit;
		this.colour = colour;
		this.level = level;
	};

	public COLOUR getColour() {
		return colour;
	}

	public void setColour(COLOUR colour) {
		this.colour = colour;
	}

	public LEVELS getLevel() {
		return level;
	}

	public void setLevel(LEVELS level) {
		this.level = level;
	}

    public void printCardDetails() {
        System.out.println("Card colour " + this.colour + "\t");
        System.out.println("Card suit " + this.suit + "\t");
        System.out.println("Card level " + this.level + "\n");
    }

}
